package spe.ui.editor.command;

import org.eclipse.gef.commands.Command;

import spe.model.spem.SPEMElement;

public class ElementRenameCommand extends Command
{
	private String oldName, newName;
	private SPEMElement model;
	
	public ElementRenameCommand()
	{
		super();
	}
	
	public ElementRenameCommand(String newName, SPEMElement model)
	{
		super();
		this.newName = newName;
		this.model = model;
	}
	
	public void setNewName(String name)
	{
		newName = name;
	}
	
	public void setModel(SPEMElement mdl)
	{
		model = mdl;
	}
	
	@Override
	public void execute()
	{
		oldName = model.getName();
		model.setName(newName);
	}
	
	@Override
	public void undo()
	{
		model.setName(oldName);
	}
}
